<cpanel include="../../config.php">

<?

/***************************************************************************
 *                                 accounts_main.php
 *                            -------------------
 *   Begin                : Thursday, April 16, 2005
 *   Copyright            : (C) 2005 Point and Code
 *   Domain               : http://www.pointandcode.com/
 *   Email                : support@pointandcode.com
 *   Version              : 1.0.0
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

$html_root_path = '../../';
include $root_path.'common.php';
$page_title = $lang['email_accounts'];
include $root_path.'page_header.php';




$big_wadge_of_stuff = <<<EOFpacman
<cpanel Email="listpopstable(disk)">
EOFpacman;


//
// let's find out the master account name
//
$temp = explode('<font size = "2">', $big_wadge_of_stuff);
$temp2 = explode('</font>', $temp[1]);

$main_account_name = $temp2[0];


//
// Let's strip out everything before the first account name
//

$end_of_main_account = strpos($big_wadge_of_stuff, "<td></td></tr>\n");

$big_wadge_of_stuff = substr($big_wadge_of_stuff, ($end_of_main_account + 14));



$array_of_accounts_with_junk = explode('</tr>', $big_wadge_of_stuff);

$array_of_accounts = array();
$i=0;

foreach($array_of_accounts_with_junk as $row) {

	$row = substr($row, 29);
	
	$temp = explode('</font>', $row);
	$array_of_accounts[$i]['address'] = $temp[0];
	
	$temp = explode('<font  size = "2">', $row);
	$temp2 = explode('</font', $temp[1]);
	
	$array_of_accounts[$i]['login'] = $temp2[0];
	
	$temp = explode("</td>\n<td><center>", $row);
	
	$array_of_accounts[$i]['currently_used'] = $temp[1];
	
	$temp2 = explode("</td>", $temp[2]);
	
	$array_of_accounts[$i]['available'] = $temp2[0];
	
	
	//
	// Splittage to make URLs later
	//
	
	$temp = explode('@', $array_of_accounts[$i]['address']);
	$array_of_accounts[$i]['email'] = $temp[0];
	$array_of_accounts[$i]['domain'] = $temp[1];
	
	$i++;
}







$template->set_filenames(array(
	'body' => $root_path.$template_path.'mail/accounts_main.tpl')
);

// Starting at one so we can have the main account as the first rowclass...
$i = 1;
foreach ($array_of_accounts as $row) {

	if (!empty($row['login'])) {
		$template->assign_block_vars('mailrow', array(
			'ROWCLASS' => ($i%2) ? $template_cfg['class_row_1'] : $template_cfg['class_row_2'],
			'ADDRESS' => $row['address'],
			'LOGIN' => $row['login'],
			'CURRENTLY_USED' => $row['currently_used'],
			'AVAILABLE' => $row['available'],
			
			'U_DELETE' => 'accounts_delete.php?email='.$row['email'].'&domain='.$row['domain'],
			'U_CHANGE_QUOTA' => 'accounts_change_quota.php?email='.$row['email'].'&domain='.$row['domain'],
			'U_CHANGE_PASS' => 'accounts_change_password.php?email='.$row['email'].'&domain='.$row['domain'],
			'U_READ_WEBMAIL' => 'webmail.php?user='.$row['address'],
			'U_AGING' => 'aging.php?user='.$row['address'],
			
			)
		);
	$i++;
	}
}


$template->assign_vars(array(
	'MAIN_ACCOUNT_NAME' => $main_account_name,
	'U_MAIN_ACCOUNT_WEBMAIL' => 'webmail_login.php',

	'L_ADDRESS' => $lang['address'],
	'L_LOGIN' => $lang['login'],
	'L_USED' => $lang['used'],
	'L_QUOTA' => $lang['quota'],
	'L_ACTIONS' => $lang['actions'],
	
	'L_ACCOUNTS_DESCRIPTION' => $lang['accounts_description'],
	'L_MAIN_ACCOUNT' => $lang['main_account'],
	'L_READ_WEBMAIL' => $lang['read_webmail'],
	'L_CHANGE_PASSWORD' => $lang['change_password'],
	'L_CHANGE_QUOTA' => $lang['change_quota'],
	'L_DELETE_ACCOUNT' => $lang['delete_account'],
	
	'L_CREATE_ACCOUNT' => $lang['create_account'],
	'L_EMAIL_ADDRESS' => $lang['email_address'],
	'L_PASSWORD' => $lang['password'],
	'L_QUOTA' => $lang['quota_optional'],
	'L_MB' => $lang['mb'],
	'L_ADD_ACCOUNT' => $lang['add_account'],
	'L_AGING' => $lang['aging'],
	
	'L_MAIN_ACCOUNT_DESCRIPTION' => sprintf($lang['main_account_description'], $html_root_path.'parser/mail/default.php'),

	'L_QUOTAS' => $lang['quotas'],
	'L_QUOTA_DESCRIPTION' => $lang['quota_description'],
	'L_CHECKING_EMAIL' => $lang['checking_email'],
	'L_CHECKING_EMAIL_DESCRIPTION' => $lang['checking_email_description'],
	)
);


$domain_list = <<<EOFpacman
<cpanel Email="listmaildomainsopt()">
EOFpacman;

//
// Add email account stuff. Does this want to be here, or on a seperate page?
//
$template->assign_vars(array(
	'S_ADD_ACTION' => "accounts_add_done.php",
	'S_DOMAIN' => $domain_list,
	)
);





//
// Woohoo! All done!
//
$template->pparse('body');




include $root_path.'page_tail.php';




?>